<?php include "header.html"; ?>

<body> 
    <div class="zss-wrap">

        <div class="zss-header">
            <span class="layui-breadcrumb">
                <?= $this->get_loc($this->baseClass, "列表"); ?>
            </span>
        </div>

        <div class="zss-nav">
            <a type="button" class="layui-btn" href="<?= U($this->baseClass . '/edit') ?>">
                <i class="layui-icon">&#xe608;</i> 添加
            </a>
        </div>

        <div class="zss-content">
            <div class="layui-tab layui-tab-brief">
				<ul class="layui-tab-title">
                    <a><li class="layui-this">管理员列表</li></a>
				</ul>
            </div>
            
            <!-- 搜索 -->
            <div class="zss-search">
                <form class="layui-form" action="<?= U($this->baseClass) ?>" method="post">

                    <div class="layui-input-inline">
                        <input name="search_key" type="text" placeholder="请输入关键字" value="<?= $search['key'] ?>" class="layui-input">
                    </div>

                    <div class="layui-input-inline">
                        <button type="submit" class="layui-btn zss-btn-submit">检索</button>
                    </div>
                </form>
            </div>

            <form class="layui-form" action="<?= U($this->baseClass . '/batch', $this->getArgs()) ?>" method="post" lay-filter="formCheck" id="formCheck">
                <table class="layui-table">
                    <thead>
                        <tr>
                            <th id="checkall">
                                <input type="checkbox" name="checkall" title="编号" lay-skin="primary">
                            </th>
                            <th>用户名</th>
                            <th class="zss-th-center">所属组</th>
                            <th class="zss-th-center">登录次数</th>
                            <th class="zss-th-center">登录IP</th>
                            <th class="zss-th-center">添加时间</th>
                            <th class="zss-th-center" width="250">相关操作</th>
                        </tr> 
                    </thead>
                    <tbody>
                        <?php foreach($result as $row) { ?>
                        <tr>
                            <td>
                                <input type="checkbox" name="id[]" lay-skin="primary" value="<?= $row['id'] ?>"><?= $row['id'] ?>
                            </td>
                            <td>
                                <?= $row['username'] ?>
                            </td>
                            <td align="center">
                                <?php
                            	
                                $goods = \core\libs\db::fetch(
                                    "group", 
                                    "group_id = ".$row['admin_group']
                                );
                                echo $goods['group_name'];
                                ?>
                            </td>
                            <td align="center"><?= $row['num'] ?></td>
                            <td align="center"><?= $row['ip'] ?></td>
                            <td align="center"><?= date('Y-m-d H:i:s', $row['time']); ?></td>
                            <td align="center">
                                <a class="layui-btn layui-btn-xs" href="<?= U($this->baseClass . '/edit', $this->getArgs('&id=' . $row['id'])) ?>">编辑</a>
                                <a class="layui-btn layui-btn-danger layui-btn-xs" href="<?= U($this->baseClass . '/delete', $this->getArgs('&id=' . $row['id'])) ?>" onclick='if(confirm("您确定删除吗?此操作将不能恢复!")){ return true; } return false;'>删除</a>
                            </td>
                        </tr>
                        <?php } ?>

                        <tr>
                            <td colspan="10" align="left">
                                <div class="layui-input-inline">
                                    <select name="action">
                                        <option value=""> 请选择需要的操作 --- </option>
                                        <option value="delete">删除 </option>
                                    </select>
                                </div>
                                <div class="layui-input-inline">
                                    <input type="submit" value="确定" class="layui-btn zss-btn-submit">
                                </div>
                            </td>
                        </tr>

                        <tr>
                            <td colspan="10" align="center" class="style_page">
                                <?= $global["page"]->show(); ?>
                            </td>
                        </tr>
                    </tbody>
                </table>
            </form>
        </div>
    </div>

    <script>
        layui.use(['element', 'form'], function() {
            let form = layui.form;

            $('#checkall').click(function() {
                app.checkAll();
                form.render('checkbox', 'formCheck');
            });
        });
    </script>
</body>
</html>
